﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Wwtfly.BBS.BackDAL.ExpertNews;
using Wwtfly.BBS.BackModels.Models.ExpertNews;
using Wwtfly.LoggerUtility;
using Wwtfly.BBS.Framework.Execption;
using Wwtfly.BBS.Framework.Common;

namespace Wwtfly.BBS.BackBLL.ExpertNews
{
   public class ExpertNewsBLL
    {
       	#region 权限和错误编码
		
		//权限编码 (默认为空,使用者需要自己修改为相应的正确编码)
		private const string MODULE_CODE = ""; 		    //模块编码
		private const string RIGHT_CODE_ADD = "";       //增加权限编码
		private const string RIGHT_CODE_UPDATE = "";    //修改权限编码
		private const string RIGHT_CODE_DELETE = "";    //删除权限编码
		
		//错误编码 (默认为不知原因的异常,使用者需要自己修改为相应的正确编码)
		private const string GET_INFO_ERROR_CODE = "9999"; 
		private const string GET_LIST_ERROR_CODE = "9999";
		private const string ADD_ERROR_CODE = "9999";
		private const string UPDATE_ERROR_CODE = "9999";
		private const string DELETE_ERROR_CODE = "9999";
		
		//错误信息
		private const string GET_INFO_ERROR_MESSAGE = "";   
		private const string GET_LIST_ERROR_MESSAGE = "";
		private const string ADD_ERROR_MESSAGE = "";
		private const string UPDATE_ERROR_MESSAGE = "";
		private const string DELETE_ERROR_MESSAGE = "";
		
		#endregion

            /// <summary>
        /// 获取专家专题分页
        /// </summary>
        /// <param name="pageParams">分页参数</param>
        /// <param name="searchModel">新闻搜索 实体类</param>
        /// <returns>分页后的结果</returns>
        public static PagedList<ExpertNewsShowsModel> GetExpertNewsShowseList(PageParams pageParams, ExpertNewsShowsSearchModel searchModel)
        {
            try
            {
                return ExpertNewsDAL.GetExpertNewsShowseList(pageParams, searchModel);
            }
            catch (Exception ex)
            {
                LoggerManage.Error(new LogMessageParams()
                {
                    ModuleID = "ExpertNewsBLL",
                    FuncCode = "PagedList<ExpertNewsShowsModel> GetExpertNewsShowseList(PageParams pageParams, ExpertNewsShowsSearchModel searchModel)",
                    Level = AppErrorLevel.EROR,
                    ErrCode = "0x0",
                    Excep = ex,
                    logMessage = "分页 获取专家专题.出错",
                    ProgramName = "Wwtilfy.BBS"
                });
                return PagedList<ExpertNewsShowsModel>.GetDefaultPageList<ExpertNewsShowsModel>();
            }
        }
          /// <summary>
       /// 用户查看专家信息查询
       /// </summary>
       /// <param name="Id"></param>
       /// <returns></returns>
        public static ExpertNewsShowsModel GetInfoshows(int userid, int expertID,out int sult)
        {
            try
            {
                return ExpertNewsDAL.GetInfoshows(userid, expertID, out sult);
            }
            catch (Exception ex)
            {
                LoggerManage.Error(new LogMessageParams()
                {
                    ModuleID = "ExpertNewsBLL",
                    FuncCode = " ExpertNewsShowsModel GetInfoshows(int userid, int expertID)",
                    Level = AppErrorLevel.EROR,
                    ErrCode = GET_INFO_ERROR_CODE,
                    Excep = ex,
                    logMessage = "查看专家信息的操作.出错",
                    ProgramName = "Wwtilfy.BBS"
                });
                throw new WwtflyBusinessException("E_" + GET_INFO_ERROR_CODE, ex);
            }
        }
        /// <summary>
        /// 查看专家信息的操作
       /// </summary>
       /// <param name="userid">用户ID</param>
       /// <param name="expertID">专家专题ID</param>
       /// <param name="UserColourMoney">用户自身金额</param>
       /// <param name="caibi">访问的彩币数量</param>
       /// <returns></returns>
        public static int ExpertLookNewsExcut(int userid, int expertID, int UserColourMoney, int caibi)
        {
            try
            {
                return ExpertNewsDAL.ExpertLookNewsExcut(userid, expertID, UserColourMoney, caibi);
            }
            catch (Exception ex)
            {
                LoggerManage.Error(new LogMessageParams()
                {
                    ModuleID = "ExpertNewsBLL",
                    FuncCode = " int ExpertLookNewsExcut(int userid, int expertID, int UserColourMoney, int caibi)",
                    Level = AppErrorLevel.EROR,
                    ErrCode = GET_INFO_ERROR_CODE,
                    Excep = ex,
                    logMessage = "查看专家信息的操作.出错",
                    ProgramName = "Wwtilfy.BBS"
                });
                throw new WwtflyBusinessException("E_" + GET_INFO_ERROR_CODE, ex);
            }
        }
            /// <summary>
       /// 获取首页的前20条预测专题
       /// </summary>
       /// <returns></returns>
        public static IList<ExpertNewsShowsModel> ExpertNewsShowsList(int ifchek)
        {
            try
            {
                return ExpertNewsDAL.ExpertNewsShowsList(ifchek);
            }
            catch (Exception ex)
            {
                
                LoggerManage.Error(new LogMessageParams()
                {
                    ModuleID = "ExpertNewsBLL",
                    FuncCode = "IList<ExpertNewsShowsModel> ExpertNewsShowsList(int ifchek)",
                    Level = AppErrorLevel.EROR,
                    ErrCode = GET_INFO_ERROR_CODE,
                    Excep = ex,
                    logMessage = "获取首页的前20条预测专题.出错",
                    ProgramName = "Wwtilfy.BBS"
                });
                throw new WwtflyBusinessException("E_" + GET_INFO_ERROR_CODE, ex);
            }
        }
        /// <summary>
        /// 根据Id获取指定的pmexpertNews
        /// </summary>
        /// <param name="Id">/*-OriginalTableName-*/主键</param>
        /// <returns>pmexpertNews实体</returns>
        public static ExpertNewsShowsModel GetInfo(Int32 Id)
        {
            try
            {
                return ExpertNewsDAL.GetInfo(Id);
            }
            catch (Exception ex)
            {
                LoggerManage.Error(new LogMessageParams()
                {
                    ModuleID = "ExpertNewsBLL",
                    FuncCode = "GetInfo(Int32 Id)",
                    Level = AppErrorLevel.EROR,
                    ErrCode = GET_INFO_ERROR_CODE,
                    Excep = ex,
                    logMessage = "根据Id获取指定的ExpertNewsShowsModel.出错",
                    ProgramName = "Wwtilfy.BBS"
                });
                throw new WwtflyBusinessException("E_" + GET_INFO_ERROR_CODE, ex);
            }
        }

        /// <summary>
        /// 添加新的pmexpertNews
        /// </summary>
        /// <param name="pmexpertNews">pmexpertNews实体</param>
        /// <returns></returns>
        public static int Add(ExpertNewsShowsModel pmexpertNews)
        {
            //如果需要检查重复值，请再下面添加代码，并要抛出业务异常

            try
            {
                int val = ExpertNewsDAL.Add(pmexpertNews);

                return val;
            }
            catch (Exception ex)
            {
                LoggerManage.Error(new LogMessageParams()
                {
                    ModuleID = "ExpertNewsBLL",
                    FuncCode = "Add(ExpertNewsShowsModel pmexpertNews)",
                    Level = AppErrorLevel.EROR,
                    ErrCode = ADD_ERROR_CODE,
                    Excep = ex,
                    logMessage = "添加新的model(专家方案).出错",
                    ProgramName = "Wwtilfy.BBS"
                });
                throw new WwtflyBusinessException("E_" + ADD_ERROR_CODE, ex);
                
            }
        }

        /// <summary>
        /// 修改pmexpertNews
        /// </summary>
        /// <param name="pmexpertNews">pmexpertNews实体</param>
        /// <returns></returns>
        public static bool Update(ExpertNewsShowsModel pmexpertNews)
        {
            try
            {
                bool val = ExpertNewsDAL.Update(pmexpertNews);

                //记录操作日志, 具体需要使用哪种记录日志的方法，请使用者自己判断
              

                return val;
            }
            catch (Exception ex)
            {
                LoggerManage.Error(new LogMessageParams()
                {
                    ModuleID = "ExpertNewsBLL",
                    FuncCode = "Update(ExpertNewsShowsModel pmexpertNews)",
                    Level = AppErrorLevel.EROR,
                    ErrCode = UPDATE_ERROR_CODE,
                    Excep = ex,
                    logMessage = "修改model(专家方案).出错",
                    ProgramName = "Wwtilfy.BBS"
                });
                throw new WwtflyBusinessException("E_" + UPDATE_ERROR_CODE, ex);
            }
        }

        /// <summary>
        /// 删除pmexpertNews
        /// </summary>
        /// <param name="Id">pm_expertNews主键</param>
        /// <returns></returns>
        public static bool Delete(Int32 Id)
        {
            try
            {
                bool val = ExpertNewsDAL.Delete(Id);
                return val;
            }
            catch (Exception ex)
            {
                LoggerManage.Error(new LogMessageParams()
                {
                    ModuleID = "ExpertNewsBLL",
                    FuncCode = " Delete(Int32 Id)",
                    Level = AppErrorLevel.EROR,
                    ErrCode = DELETE_ERROR_CODE,
                    Excep = ex,
                    logMessage = "删除model(专家方案).出错",
                    ProgramName = "Wwtilfy.BBS"
                });
                throw new WwtflyBusinessException("E_" + DELETE_ERROR_CODE, ex);
           
            }
        }
    }
}
